@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

REM == kill ppstream process ==
TASKKILL /F /IM "PPStream.exe" /T

REM == delete all pps ads directories ==
RMDIR /s /q "%APPDATA%\PPStream\banner"
ECHO banner >> "%APPDATA%\PPStream\banner"
RMDIR /s /q "%APPDATA%\PPStream\adsys"
ECHO adsys >> "%APPDATA%\PPStream\adsys"

REM == detect ppstream director ==
SET pps_dirs="%ProgramFiles%",C:\PPS.tv,D:\PPS.tv

FOR %%A IN (%pps_dirs%) DO (
  SET pps_cmd="%%~A\PPStream\PPStream.exe"
  IF EXIST "!pps_cmd!" (
    START "PPStream" /MAX /WAIT ""!pps_cmd!"" >> "%APPDATA%\PPStream\adsys"
    GOTO end
  )
)

:end
ENDLOCAL 